<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', function () use ($router) {
    //return $router->app->version();
    $config = file_get_contents('config.json');
    $res = json_decode($config, true);
    if ($res['period'] < date('YmdHis', time())) {
        return '您的授权已过期！请联系开发者！';
    }
    return redirect('/index.html');
//    $client_w = isset($_REQUEST['client_width'])&&$_REQUEST['client_width'] ? $_REQUEST['client_width'] : 0;
//    if (!$client_w || $client_w > 500) {
//        return redirect('/admin/index.html');
//    } else {
//        return redirect('/h5/index.html');
//    }
});


//后台管理API
$router->group(['prefix'=>'/api/admin', 'namespace'=>'Admin'], function () use ($router) {
    $router->post('dologin', 'LoginController@dologin');
    $router->post('leftmenu', 'LoginController@leftMenu');
    $router->get('config/modify', 'LoginController@configSet');
    $router->get('config/index', 'LoginController@configGet');
    //模块管理
    $router->post('action/index', 'ActionController@index');
    $router->post('action/modify', 'ActionController@modify');
    //角色管理
    $router->post('role/index', 'RoleController@index');
    $router->post('role/modify', 'RoleController@modify');
    $router->post('role/del', 'RoleController@del');
    $router->post('role/actlist', 'RoleController@actList');
    $router->post('role/setauth', 'RoleController@setAuth');
    //员工管理
    $router->post('staff/index', 'StaffController@index');
    $router->post('staff/option', 'StaffController@getOption');
    $router->post('staff/modify', 'StaffController@modify');
    $router->post('staff/toable', 'StaffController@toable');
    $router->post('staff/reset', 'StaffController@reset');
    $router->post('staff/pwdmodify', 'StaffController@pwdmodify');
    //部门
    $router->post('depart/index', 'DepartController@index');
    $router->post('depart/modify', 'DepartController@modify');
    $router->post('depart/del', 'DepartController@del');
    //项目
    $router->post('config/item/index', 'ItemController@index');
    $router->post('config/item/option', 'ItemController@getOption');
    $router->post('config/item/modify', 'ItemController@modify');
    $router->post('config/item/del', 'ItemController@del');
    $router->post('config/item/team-get', 'ItemController@teamGet');
    $router->post('config/item/team-set', 'ItemController@teamSet');
    $router->post('config/item/team-del', 'ItemController@teamDel');
    //工时
    $router->post('config/wh/index', 'WorkhourController@index');
//    $router->post('config/wh/option', 'WorkhourController@getOption');
    $router->post('config/wh/modify', 'WorkhourController@modify');
    $router->post('config/wh/del', 'WorkhourController@del');
    $router->post('config/wh/cnt/modify', 'WorkhourController@cntModify');
    //任务
    $router->post('task/index', 'TaskController@index');
    $router->post('task/modify', 'TaskController@modify');
    $router->post('task/del', 'TaskController@del');
    //工时
    $router->post('wh/index', 'WhywController@index');
//    $router->post('wh/option', 'WhywController@getOption');
    $router->post('wh/one', 'WhywController@getOne');
    $router->post('wh/setbyitem', 'WhywController@setByItem');
    $router->post('wh/item-default/modify', 'WhywController@itemDefault');
//    $router->post('wh/config-wh/index', 'WhywController@getConfigWhList');
//    $router->post('wh/jisuan', 'WhywController@jisuan');
    $router->post('wh/modify', 'WhywController@modify');
    $router->post('wh/del', 'WhywController@del');
    $router->post('wh/auth-index', 'WhywController@authIndex');
    $router->post('wh/auth-ok', 'WhywController@authOk');
    $router->post('wh/auth-no', 'WhywController@authNo');
    $router->post('whitem/one', 'WhitemController@getOne');
    $router->post('whitem/delay-get', 'WhitemController@getDelay');
    $router->post('whitem/modify', 'WhitemController@modify');
    $router->post('whitem/del', 'WhitemController@del');
    $router->post('whitem/detailbyid', 'WhitemController@detailById');
    $router->post('whitem/cnt-get', 'WhitemController@getCntList');
    //统计
//    $router->post('tongji/index', 'WhywController@tongji');
    $router->post('tongji/person', 'TongjiController@person');
    $router->post('tongji/item', 'TongjiController@item');
    $router->post('tongji/all', 'TongjiController@all');
    $router->post('tongji/huan', 'TongjiController@huan');
    $router->post('tongji/tu', 'TongjiController@tu');
    //测试导出
    $router->post('tongji/option', 'TongjiController@getOption');
    $router->get('tongji/excel/test', 'TongjiController@excelTest');
    $router->get('tongji/staff-month-out', 'TongjiController@staffMonthOut');
});


//H5管理API
$router->group(['prefix'=>'/api/h5', 'namespace'=>'H5'], function () use ($router) {
    $router->post('dologin', 'LoginController@dologin');
    $router->post('bommenu', 'LoginController@bomMenu');
    $router->post('wsmenu', 'LoginController@wsMenu');
    //首页
    $router->post('index/index', 'IndexController@index');
    $router->post('index/auth-no', 'IndexController@authNo');
    $router->post('index/auth-ok', 'IndexController@authOk');
    $router->post('index/auth-modify', 'IndexController@authModify');
    $router->post('index/auth-reply', 'IndexController@authReply');
    //统计
    $router->post('tongji/index', 'IndexController@tongji');
    //部门
    $router->post('depart/index', 'DepartController@index');
    $router->post('depart/modify', 'DepartController@modify');
    //项目
    $router->post('item/index', 'ItemController@index');
//    $router->post('item/modify', 'ItemController@modify');
    //工时项
    $router->post('workhour/index', 'WorkhourController@index');
//    $router->post('workhour/modify', 'WorkhourController@modify');
    //人员
    $router->post('staff/index', 'StaffController@index');
    $router->post('staff/modify', 'StaffController@modify');
    //任务
    $router->post('task/index', 'TaskController@index');
    $router->post('task/modify', 'TaskController@modify');
    //工时录入
    $router->post('whyw/index', 'WhywController@index');
    $router->post('whyw/one', 'WhywController@getOne');
    $router->post('whyw/modify', 'WhywController@modify');
    $router->post('whyw/auth-list', 'WhywController@authList');
    $router->post('whyw/auth-set', 'WhywController@authSet');
    $router->post('whitem/one', 'WhitemController@getOne');
    $router->post('whitem/modify', 'WhitemController@modify');
    $router->post('whitem/del', 'WhitemController@del');
});